package com.htudata.transctLive.dao;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import java.util.List;
import java.util.Map;

import com.htudata.transctLive.mapper.TransctLiveMapper;
import com.htudata.transctLive.zabbix.mapper.ZabbixTransctLiveMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

@Repository
public class TransctLiveDao {
  @Autowired
  private TransctLiveMapper liveMapper;
  
  @Autowired
  private ZabbixTransctLiveMapper zabbixLiveMapper;
  
  public JSONArray getAllDataType() {
    return this.liveMapper.getAllDataType();
  }
  
  public List<Map<String, Object>> selectDataTypeListAndFlowList() {
    return this.liveMapper.selectDataTypeListAndFlowList();
  }
  
  public List<Map<String, Object>> selectFlowsAndNodesByFlowId(List<String> flowIdList, List<Long> userIds2) {
    JSONObject params = new JSONObject();
    params.put("flowIdList", flowIdList);
    params.put("userIds2", userIds2);
    params.put("page", Integer.valueOf(0));
    params.put("perPage", Long.valueOf(Long.MAX_VALUE));
    return this.liveMapper.selectFlowsAndNodesByFlowId(params);
  }
  
  public List<Map<String, Object>> selectFlowsAndNodesByFlowId2(List<String> flowIdList, int nodeTypeId, int childNodeTypeId, int stationTypeId, List<Long> userIds, int page, int perPage) {
    JSONObject params = new JSONObject();
    params.put("flowIdList", flowIdList);
    params.put("nodeTypeId", Integer.valueOf(nodeTypeId));
    params.put("childNodeTypeId", Integer.valueOf(childNodeTypeId));
    params.put("stationTypeId", Integer.valueOf(stationTypeId));
    params.put("userIds", userIds);
    params.put("flowName", "");
    params.put("nodeNickName", "");
    params.put("page", Integer.valueOf(page));
    params.put("perPage", Integer.valueOf(perPage));
    return this.liveMapper.selectFlowsAndNodesByFlowId(params);
  }
  
  public List<Map<String, Object>> selectFlowsAndNodesByFlowIdV2(List<String> flowIdList, int nodeTypeId, int childNodeTypeId, int stationTypeId, List<Long> userIds, int page, int perPage) {
    JSONObject params = new JSONObject();
    params.put("flowIdList", flowIdList);
    params.put("nodeTypeId", Integer.valueOf(nodeTypeId));
    params.put("childNodeTypeId", Integer.valueOf(childNodeTypeId));
    params.put("stationTypeId", Integer.valueOf(stationTypeId));
    params.put("userIds", userIds);
    params.put("flowName", "");
    params.put("nodeNickName", "");
    params.put("page", Integer.valueOf(page));
    params.put("perPage", Integer.valueOf(perPage));
    return this.liveMapper.selectFlowsAndNodesByFlowIdV2(params);
  }
  
  public List<Map<String, Object>> selectAllFlowsAndNodesByFlowId2(List<String> flowIdList, int nodeTypeId, int childNodeTypeId, int stationTypeId, List<Long> userIds, int page, int perPage) {
    JSONObject params = new JSONObject();
    params.put("flowIdList", flowIdList);
    params.put("nodeTypeId", Integer.valueOf(nodeTypeId));
    params.put("childNodeTypeId", Integer.valueOf(childNodeTypeId));
    params.put("stationTypeId", Integer.valueOf(stationTypeId));
    params.put("userIds", userIds);
    params.put("flowName", "");
    params.put("nodeNickName", "");
    params.put("page", Integer.valueOf(page));
    params.put("perPage", Integer.valueOf(perPage));
    return this.liveMapper.selectAllFlowsAndNodesByFlowId(params);
  }
  
  public List<Map<String, Object>> selectFlowsAndNodesByFlowId3(List<String> flowIdList, int nodeTypeId, int childNodeTypeId, int stationTypeId, List<Long> userIds, String flowName, String nodeNickName) {
    JSONObject params = new JSONObject();
    params.put("flowIdList", flowIdList);
    params.put("nodeTypeId", Integer.valueOf(nodeTypeId));
    params.put("childNodeTypeId", Integer.valueOf(childNodeTypeId));
    params.put("stationTypeId", Integer.valueOf(stationTypeId));
    params.put("userIds", userIds);
    params.put("flowName", flowName);
    params.put("nodeNickName", nodeNickName);
    params.put("page", Integer.valueOf(0));
    params.put("perPage", Long.valueOf(Long.MAX_VALUE));
    return this.liveMapper.selectFlowsAndNodesByFlowId(params);
  }
  
  public List<Map<String, Object>> selectLinksByFlowId(List<String> flowIdList) {
    return this.liveMapper.selectLinksByFlowId(flowIdList);
  }
  
  public int deleteTempNodesByFlowId(String flowId) {
    return this.liveMapper.deleteTempNodesByFlowId(flowId);
  }
  
  public JSONArray countNodeZabbixProblem() {
    return this.zabbixLiveMapper.countNodeZabbixProblem();
  }
  
  public JSONArray countFlowZabbixItem() {
    return this.zabbixLiveMapper.countFlowZabbixItem();
  }
  
  public JSONArray countNodeProblem() {
    return this.liveMapper.countNodeProblem();
  }
  
  public JSONArray countFlowItem() {
    return this.liveMapper.countFlowItem();
  }
  
  public JSONArray selectVirtualNodesByNodeId(String nodeId, int V02001, String V01301, String stationName, String V_PRCODE, String V_CITY, String V_ADDRESS, int rowIndex, int pageSize, int nodeTypeId) {
    JSONObject params = new JSONObject();
    params.put("nodeId", nodeId);
    params.put("nodeTypeId", Integer.valueOf(nodeTypeId));
    params.put("rowIndex", Integer.valueOf(rowIndex));
    params.put("pageSize", Integer.valueOf(pageSize));
    params.put("V02001", Integer.valueOf(V02001));
    params.put("V01301", V01301);
    params.put("stationName", stationName);
    params.put("V_PRCODE", V_PRCODE);
    params.put("V_CITY", V_CITY);
    params.put("V_ADDRESS", V_ADDRESS);
    return this.liveMapper.selectVirtualNodesByNodeId(params);
  }
  
  public JSONObject selectVirtualStationCountByNodeId(String nodeId, int nodeTypeId) {
    return this.liveMapper.selectVirtualStationCountByNodeId(nodeId, nodeTypeId);
  }
  
  public JSONArray selectVirtualStationList(int nodeTypeId, String nodeId, String areaCode, int level, List<Long> userIds) {
    return this.liveMapper.selectVirtualStationList(nodeTypeId, nodeId, areaCode, level, userIds);
  }
  
  public JSONObject selectGlobalConf() {
    return this.liveMapper.selectGlobalConf();
  }
  
  public JSONArray getAreaList(String prov) {
    return this.liveMapper.getAreaList(prov);
  }
  
  public JSONArray getStatisVirtualStation(int nodeTypeId, String nodeId, String areaCode, int level, List<Long> userIds, String prov) {
    return this.liveMapper.getStatisVirtualStation(nodeTypeId, nodeId, areaCode, level, userIds, prov);
  }
}
